package com.neusoft.neu24.controller;

import com.neusoft.neu24.Result.CommonResult;
import com.neusoft.neu24.dto.*;
import com.neusoft.neu24.entity.Feedback;
import com.neusoft.neu24.entity.FeedbackInfo;
import com.neusoft.neu24.service.impl.FeedbackServiceImpl;
import io.swagger.models.auth.In;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;
import java.util.List;

/**
 * <p>
 * 监督反馈表 前端控制器
 * </p>
 *
 * @author fyc
 * @since 2024-06-18
 */
@RestController
@RequestMapping("/feedback")
public class FeedbackController {

    @Resource
    private FeedbackServiceImpl feedbackService;

    @GetMapping("/list")
    public CommonResult<List<Feedback>> listAll() {
        return feedbackService.listAll();
    }

    @PostMapping("/p/add")
    public CommonResult<Integer> addFeedbackByPublic(@RequestBody Feedback feedback) {
        return feedbackService.addFeedbackByPublic(feedback);
    }

    @GetMapping("/p/history/{pid}")
    public CommonResult<List<Feedback2PublicDTO>> listAllByPid(@PathVariable("pid") Integer pid) {
        return feedbackService.listAllByPid(pid);
    }

    @GetMapping("/p/info/{fid}")
    public CommonResult<FeedbackInfo> getInfoByFid(@PathVariable("fid") Integer fid) {
        return feedbackService.getInfoByFid(fid);
    }
    @GetMapping("/p/info")
    public CommonResult<List<FeedbackInfo>> getInfos() {
        return feedbackService.getInfos();
    }

    @GetMapping("/p/timeline/{id}")
    public CommonResult<List<TimeLineDTO>> getTimeLines(@PathVariable Integer id) {
        return feedbackService.getTimeLines(id);
    }


    @GetMapping("/g/todo/{gid}")
    public CommonResult<List<Feedback2GridDTO>> getTodoListByGid(@PathVariable("gid") Integer gid) {
        return feedbackService.getTodoListByGid(gid);
    }

    @PostMapping("/g/commit/{fid}")
    public CommonResult<FeedbackInfo> getAQI(@RequestBody FeedbackInfo info, @PathVariable Integer fid) {
        return feedbackService.commitFeedback(info,fid);
    }

    @GetMapping("/g/his/{gid}")
    public CommonResult<List<FeedbackHis2GridDTO>> getHisByGid(@PathVariable Integer gid) {
        return feedbackService.getHisByGid(gid);
    }

    @GetMapping("/a/undo")
    public CommonResult<List<FeedbackInfo2AdminDTO>> getUndo() {
        return feedbackService.getUndo();
    }

    @GetMapping("/a/list")
    public CommonResult<List<Feedback2AdminDTO>> getList() {
        return feedbackService.getList();
    }

    @GetMapping("/a/pcr")
    public CommonResult<GridGroupDTO> getPCRs() {
        return feedbackService.getPCRs();
    }

    @PostMapping("/a/distribute")
    public CommonResult<FeedbackInfo2AdminDTO> distribute(@RequestBody Feedback feedback) {
        return feedbackService.distribute(feedback);
    }
}
